#include<stdio.h>
#include<math.h>

void hanoi(int n, char src, char aux, char tar)
{
    if(n == 1)
    {
        printf("%c To %c\n", src, tar);
    }
    else
    {
        hanoi(n - 1, src, tar, aux);

        printf("%c To %c\n", src, tar);

        hanoi(n - 1, aux, src, tar);
    }
}

int main()
{
    int n;
    scanf("%d", &n);

    hanoi(n, 'A', 'B', 'C');

    printf("%d", (int)(pow(2, n) - 1));

    return 0;
}
